package com.hison.controller;

import com.hison.service.UploadService;
import com.hison.util.ResponseResult;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: UploadController
 * @Descripiton: TODO
 * @Author: 小郑
 * @Date： 2024/1/13 20:40
 * @Version：1.8
 **/
@RestController
public class UploadController {
    @Autowired
    private UploadService uploadService;

    @ApiOperation("上传文件到OSS")
    @PostMapping("/upload")
    public  ResponseResult upload(@RequestParam("img") MultipartFile file) {

        return  uploadService.upload(file);
    }

    @ApiOperation("删除OOS服务器的文件")
    @ApiImplicitParam(name="fileUrl", value="要删除的文件URL", required=true)
    @DeleteMapping("/delete")
    public ResponseResult delete(@RequestParam(value = "fileUrl", required = false) String fileUrl) {
        return uploadService.delete(fileUrl);
    }
}